<template>
    <div>
        挂号编号：{{number}}

        <el-divider></el-divider>
        <el-row>
            <el-col :span="8"><div   class="grid-content bg-purple">患者信息
                <el-form ref="form"  :inline="true" :model="patient" label-width="80px">
                    <el-form-item label="姓名" >
                        <el-input v-model="patient.name" style="width: 150px"></el-input>
                    </el-form-item>
                    <el-form-item label="性别">
                        <el-select v-model="patient.sex"  style="width: 150px">
                            <el-option label="男" value="1"></el-option>
                            <el-option label="女" value="2"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="生日">
                        <el-col :span="11">
                            <el-date-picker type="date" placeholder="选择日期" v-model="patient.birthday" style="width: 220px;" value-format="yyyy-MM-dd" ></el-date-picker>
                        </el-col>
                    </el-form-item>
                    <el-form-item label="手机">
                        <el-input type="number" v-model="patient.mobile"  style="width: 220px" ></el-input>
                    </el-form-item>
                    <el-form-item label="身份证">
                        <el-input type="number" v-model="patient.idCard" style="width: 220px" ></el-input>
                    </el-form-item>
                    <el-form-item label="住址">
                        <el-input type="textarea" v-model="patient.address" style="width: 220px" ></el-input>
                    </el-form-item>
                </el-form>
            </div></el-col>



            <el-col :span="16"><div class="grid-content bg-purple-light">
                <el-form :inline="true" :model="params" class="demo-form-inline">
                    <el-form-item label="科室:">
                        <el-select v-model="params.departmentId" placeholder="全部科室" style="width: 120px">
                            <el-option v-for="department in departments"
                                       :label="department.departmentName" :key="department.did" :value="department.did"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="医生:">
                        <el-select v-model="params.physicianId" placeholder="全部医生" style="width: 120px">
                            <el-option v-for="docker in dockers"
                                       :label="docker.trueName" :key="docker.id" :value="docker.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="挂号类型:">
                        <el-select v-model="params.registeredfeeId" placeholder="全部挂号类型" style="width: 140px">
                            <el-option v-for="hisRegisteredfee in hisRegisteredfees"
                                       :label="hisRegisteredfee.registeredfeeName" :key="hisRegisteredfee.regId" :value="hisRegisteredfee.regId"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="挂号日期">
                        <el-col :span="11">
                            <el-date-picker type="date" placeholder="选择日期" v-model="params.createTime" style="width: 140px;" value-format="yyyy-MM-dd" ></el-date-picker>
                        </el-col>
                    </el-form-item>
                    <el-form-item label="时间段">
                        <el-select v-model="params.schedulingSubsectionId"  style="width: 100px">
                            <el-option label="上午" value="1"></el-option>
                            <el-option label="中午" value="2"></el-option>
                            <el-option label="下午" value="3"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="search">查询</el-button>
                    </el-form-item>
                </el-form>
            </div>
                <div>
                    <el-table
                            :data="pageResult.records"
                            border
                            style="width: 100%">
                        <el-table-column
                                label="医生姓名">
                            <template slot-scope="scope" >
                                {{scope.row.trueName}}
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="科室名称">
                            <template slot-scope="scope" >
                                {{scope.row.hisMemberEntities.hisDepartmentEntities.departmentName}}
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="挂号类型">
                            <template slot-scope="scope" >
                                {{scope.row.hisMemberEntities.hisRegisteredfeeEntity.registeredfeeName}}
                            </template>
                        </el-table-column>
                        <el-table-column
                                label="挂号费">
                            <template slot-scope="scope" >
                                {{scope.row.hisMemberEntities.hisRegisteredfeeEntity.registeredfeeAggregateAmount}}
                            </template>
                        </el-table-column>
                        <el-table-column
                                fixed="right"
                                label="操作">
                            <template slot-scope="scope">
                                <el-button @click="lookdate(scope.row)" type="text" size="small">查看工作时间</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>

            </el-col>
        </el-row>



        <el-dialog title="医生挂号时间" :visible.sync="dialogFormVisibledate">
            <el-table
                    :data="dockerWordDate"
                    border
                    style="width: 100%">
                <el-table-column
                        label="工作时间">
                    <template slot-scope="scope" >
                        {{scope.row.subsectionType=='1'?'上午':scope.row.subsectionType=='2'?'中午':'晚上'}}
                    </template>
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作">
                    <template slot-scope="scope">
                        <el-button @click="lookdate1(scope.row)" type="text" size="small">查看工作时间</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>

        <el-dialog title="医生周期" :visible.sync="dialogFormVisibledate1">
            <el-table
                    :data="dockerWordDate1"
                    border
                    style="width: 100%">
                <el-table-column
                        label="工作时间">
                    <template slot-scope="scope" >
                        {{scope.row.week==1?'星期一':(scope.row.week==2?'星期二':(scope.row.week==3?'星期三':(scope.row.week==4?'星期四':(scope.row.week==5?'星期五':(scope.row.week==6?'星期六':'星期天')))))}}

                    </template>
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作">
                    <template slot-scope="scope">
                        <el-button @click="add(scope.row)" type="text" size="small">挂这</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>






        <el-footer class="case-exam-footer">
            <el-pagination
                    background
                    layout="prev, pager, next"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
            >
            </el-pagination>
        </el-footer>

    </div>
</template>

<script>


    import HisRegistration from '../../model/mfy/HisRegistration.js'
    const hisRegistration =HisRegistration.getInstance();

    import HisRegisteredfee from '../../model/mfy/HisRegisteredfee.js'
    const hisRegisteredfee = HisRegisteredfee.getInstance();


    export default {
        name: "HisRegistrationAdd.vue",
        data(){
            return{
                number:'',
                departments:[], //科室信息
                hisRegisteredfees:{}, //挂号类型
                dockers:[], //医生信息
                patient:{}, //患者信息
                pageResult:{}, //page对象
                params:{},     //高级查询参数对象
                dockerWordDate:[],
                dialogFormVisibledate:false,
                dialogFormVisibledate1:false,
                dockerWordDate1:[],
                hisRegistration:{},
            }
        },
        methods:{
            getNumber(){
                hisRegistration.getNumber().then((response)=>{
                    this.number=response.data.data;
                })
            },
            departmentList(){
                hisRegistration.departmentList().then((response)=>{
                    this.departments=response.data.departmentList.data
                })
            },
            HisRegisteredfeeList(){
                hisRegisteredfee.listNoPage().then((response)=>{
                    this.hisRegisteredfees=response.data.data
                })
            },
            dockerList(){
                hisRegistration.dockerList().then((response)=>{
                    this.dockers=response.data.dockerList.dockerList
                })
            },
            handleIndexChange(index){
                this.params.page = index
                this.list()
            },
            search(){
                this.params.page=1
                this.list()
            },
            list(){
                hisRegistration.list(this.params).then(response=>{
                    this.pageResult = response.data.page
                })
            },
            lookdate(row){
                this.hisRegistration.physicianId=row.id
                this.hisRegistration.departmentId=row.hisMemberEntities.hisDepartmentEntities.did
                this.hisRegistration.registeredfeeId=row.hisMemberEntities.hisRegisteredfeeEntity.regId
                this.hisRegistration.operatorId=0
                this.hisRegistration.registrationAmount=row.hisMemberEntities.hisRegisteredfeeEntity.registeredfeeAggregateAmount
                this.dialogFormVisibledate = true
                this.hisRegistration.schedulingId=row.hisSchedulingEntity[0].schedulingId
                this.dockerWordDate=row.hisSchedulingEntity[0].hisSchedulingSubsectionEntities;
            },
            lookdate1(row){
                this.hisRegistration.schedulingSubsectionId=row.schedulingSubsectionId
                this.dialogFormVisibledate1 = true
                this.dockerWordDate1=row.hisSchedulingWeekEntity;
            },
            add(row){
                this.hisRegistration.schedulingWeekId=row.schedulingWeekId;
                this.hisRegistration.registrationNumber=this.number
                var aa={};
                aa.patientEntity=this.patient
                aa.hisRegistration=this.hisRegistration
                hisRegistration.add(aa).then(()=>{
                    this.dialogFormVisibledate=false;
                    this.dialogFormVisibledate1=false;
                })
            }
        },
        created() {
            this.list()
            this.getNumber()
            this.departmentList()
            this.dockerList()
            this.HisRegisteredfeeList()
        },
        watch: {
            dialogFormVisibledate:function () {
                if(this.dialogFormVisibledate==false){
                    this.dockerWordDate=[]
                }
            },

            dialogFormVisibledate1:function () {
                if(this.dialogFormVisibledate1==false){
                    this.dockerWordDate1=[]
                }
            }
        },
    }
</script>

<style scoped>

</style>
